package com.settlement.system.rules;

import com.settlement.system.model.entity.SysAudit;
import com.settlement.system.model.entity.SysAuditRule;

import java.math.BigDecimal;

/**
 * 8、已收款已退款已发货已退货
 * (全sku退货退款）
 */
public class AllGoodsReturnRuler implements CommonRuler{
    @Override
    public boolean check(SysAudit sysAudit, SysAuditRule auditRule) {
        // 应收账余额=0
        //且收款金额＞0
        //且退款金额+保证金退款金额<0
        //且发货金额＞0
        //且退货金额＜0
        return BigDecimal.ZERO.compareTo(sysAudit.getReceiveBillAmount()) == 0 &&
                sysAudit.getReceiveAmount().compareTo(BigDecimal.ZERO) > 0 &&
                (sysAudit.getRefundAmount().add(sysAudit.getDepositAmount())).compareTo(BigDecimal.ZERO) < 0 &&
                sysAudit.getSendAmount().compareTo(BigDecimal.ZERO) > 0 &&
                sysAudit.getReturnAmount().compareTo(BigDecimal.ZERO) < 0;
    }
}
